package screenpac.features;

import java.awt.Color;

import screenpac.model.GameStateInterface;
import screenpac.model.Node;

public class GaiNearFarPillDistance {
	static int max = Integer.MAX_VALUE;
	static int min = Integer.MIN_VALUE; //Luis

    // this can be useful: make it public
    public Node closest = null;
    public Node farthest = null; //Luis

    public double score(GameStateInterface gs, Node node) {
        // most obvious way: iterate over the set of pills
        // int closest
        int minDist = max;
        int maxDist = min; //Luis
        for (Node n : gs.getMaze().getPills()) {
            // check the state of this pill
            // by querying the BitSet of pill states
            if (gs.getPills().get(n.pillIndex)) {
                // this pill is on, but is it closer?
                if (gs.getMaze().dist(node, n) < minDist) {
                    minDist = gs.getMaze().dist(node, n);
                    closest = n;
                }
                //Luis:
                if(gs.getMaze().dist(node, n) > maxDist) {
                	maxDist = gs.getMaze().dist(node, n);
                	farthest = n;
                }
            }
        }
        if (closest != null) {
            closest.col = Color.green;
        }
        if(farthest != null) {
        	//farthest.col = Color.orange;
        }
        return minDist;
    }
}
